home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / sets11.zip / SetTest.CPP < prev    next >
C/C++ Source or Header  |  1997-04-09  |  1KB  |  41 lines

  1. // Test program for Sets by Hubert Chan
  2. // April 9, 1997
  3.  
  4. #include "Sets.HPP"
  5. #include <StdIO.H>
  6.  
  7. #define Test(x) (x ? "is\0" : "is not\0")
  8.  
  9. void main() {
  10.     Set::SetElement Aarray[3] = { 1,2,3 };
  11.     Set A(3,Aarray);
  12.     Set::SetElement Barray[3] = { 2,3,4 };
  13.     Set B(3,Barray);
  14.     Set::SetElement Carray[2] = { 2,3 };
  15.     Set C(2,Carray);
  16.     printf("****************************************\n");
  17.     printf("* Test program for Sets by Hubert Chan *\n");
  18.     printf("* Last modified: Apr 9, 1997           *\n");
  19.     printf("****************************************\n\n");
  20.     printf("A = "); PrintSet(A);
  21.     printf("B = "); PrintSet(B);
  22.     printf("C = "); PrintSet(C);
  23.     printf("A U B = "); PrintSet(A + B);
  24.     printf("A ^ B = "); PrintSet(A * B);
  25.     printf("A - B = "); PrintSet(A - B);
  26.     printf("~A = "); PrintSet(~A);
  27.     printf("2 %s in A\n", Test(2<=A));
  28.     printf("5 %s in A\n", Test(5<=A));
  29.     printf("C %s a subset of A\n", Test(C<=A));
  30.     printf("C %s a proper subset of A\n", Test(C<A));
  31.     printf("C %s equal to A\n", Test(C==A));
  32.     printf("C %s not equal to A\n", Test(C!=A));
  33.     printf("A %s a subset of A\n", Test(A<=A));
  34.     printf("A %s a proper subset of A\n", Test(A<A));
  35.     printf("A %s equal to A\n", Test(A==A));
  36.     printf("A %s not equal to A\n", Test(A!=A));
  37.     printf("A %s a superset of C\n", Test(A>=C));
  38.     printf("A %s a proper superset of C\n", Test(A>C));
  39. }
  40.  
  41.